;; EX-07.scm - Mapping Arguments to Sequential Control Busses

;; Define a synth to play a sine wave with bus, frequency and
;; amplitude parameters.

(synthdef-send
 (synthdef
  "sine"
  ((out 0) (freq 440) (ampl 0.1))
  (Out.ar out (SinOsc.ar freq 0 ampl))))

;; Define a synth to write to a control bus.

(synthdef-send
 (synthdef
  "line"
  ((bus 0) (start 1000) (end 500) (time 1))
  (ReplaceOut.kr bus (Line.kr start end time))))

;; Start sine wave node.

(-> "/s_new" "sine" 1000 1 1)

;; Put values on the control busses.

(-> "/c_setn" 10 3 0 1000 0.05)

;; Map node arguments to read from control busses starting at #10.

(-> "/n_mapn" 1000 0 10 3)

;; Change the values on the control busses.

(-> "/c_setn" 10 3 1 200 0.1)

;; Start a control process that writes to control bus #11.

(-> "/s_new" "line" 1001 1 1 "bus" 11)

;; Free the control node.

(-> "/n_free" 1001)

;; Change the values on the control busses.

(-> "/c_setn" 10 3 0 300 0.2)

;; Free signal node.

(-> "/n_free" 1000)
